﻿//=============================================================================
// Project  : NIPO Component Framework
// File    : Program.cs
// Author  : Bernhard Dieber (Bernhard.Dieber@uni-klu.ac.at)
// Copyright 2010 by Bernhard Dieber
// This code is published under the Microsoft Public License (Ms-PL).  A copy
// of the license should be distributed with the code.  It can also be found
// at the project website: http://NIPO.CodePlex.com.   This notice, the
// author's name, and all copyright notices must remain intact in all
// applications, documentation, and source files.
//=============================================================================

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using NIPO.Controller;
using NIPOPlugins.Input;
using NIPOPlugins.Output;
using NIPOPlugins.Processing;

/*
 * This example application loads the plugins from the NIPOPlugins projects and starts the application
 */
namespace NIPOExamples
{
    class Program
    {
        static void Main(string[] args)
        {
            /*
             * Since we know what plugins to load, we do not search for them but instantiate them directly. This is how you most probably will use NIPO inside another application
             */
            SimpleInputPlugin input = new SimpleInputPlugin
                                          {
                                              ConfigurationObject =
                                                  new SimpleInputConfiguration {Filename = "input.txt"}
                                          };
            NIPOController.Instance.AddInputPlugIn(input);
            SimpleOutputPlugin output = new SimpleOutputPlugin
                                            {
                                                ConfigurationObject =
                                                    new SimpleOutputConfiguration {TargetFile = "output.txt"}
                                            };
            NIPOController.Instance.AddOutputPlugin(output);
            SimpleProcessingPlugin processing = new SimpleProcessingPlugin();
            NIPOController.Instance.AddProcessingPlugin(processing);
            /*
             * We have instanciated, configured and added all plugins (we need at least input and output, processing is optional)
             * Now we can start this instance
             */
            NIPO.Util.Logger.InitLogging();
            NIPOController.Instance.StoreToYAML(new FileInfo("out.xml"));
            NIPOController.Instance.LoadFromYAML("out.xml");
            return;
            NIPOController.Instance.Start();
            //This is just to be sure, the operation is finished. In the next version of NIPO we will include events for the plugins to signal that they are finished
            Thread.Sleep(10000);
            Console.WriteLine("Finished. Press any key to exit");
            Console.ReadKey();

        }
    }
}
